<html>
<head><meta charset="utf-8"><title>Yield closures lang-team#49 · t-lang/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/index.html">t-lang/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html">Yield closures lang-team#49</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208310636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208310636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208310636">(Aug 28 2020 at 06:47)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/lang-team/issues/49">Yield closures #49</a>. It will be announced at the next meeting to try and draw attention to it, but usually MCPs are not discussed during triage meetings. If you think this would benefit from discussion amongst the team, consider proposing a design meeting.</p>



<a name="208334885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208334885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208334885">(Aug 28 2020 at 12:16)</a>:</h4>
<p>(cc me)</p>



<a name="208352589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208352589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208352589">(Aug 28 2020 at 14:53)</a>:</h4>
<p>I'm not opposed to the idea, but I think that the timing isn't right. I feel like we should be focused on closing up work, not opening large new avenues.</p>



<a name="208352635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208352635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208352635">(Aug 28 2020 at 14:53)</a>:</h4>
<p>I do think we're going to want to look into generator functions</p>



<a name="208352684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208352684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208352684">(Aug 28 2020 at 14:53)</a>:</h4>
<p>And I think that would be a time to think over the possibility of a more general syntax as well</p>



<a name="208352776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208352776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208352776">(Aug 28 2020 at 14:54)</a>:</h4>
<p>(though I'm not sure yet if I think it makes sense to do something more targeted at just writing iterators/streams, or whether to try and attack the general problem)</p>



<a name="208376713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208376713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208376713">(Aug 28 2020 at 18:08)</a>:</h4>
<p>That is a fair concern! But personally I'd argue that this is all about closing up work. Rust has had unstable coroutines for a long while now and the ecosystem wants to use them. We just haven't polished the feature up enough to be stablizable. From my stalled rustc prototyping, I've gotten the impression that turning the current unstable generators into MVP yield closures is really not that huge a task:</p>
<ol>
<li>add the witness to the closure type variables</li>
<li>add FnPin to core</li>
<li>teach closures when to implement FnPin</li>
<li>update the mir transform to do argument reassignment, not do enum-wrapping</li>
<li>nuke ty::Generator</li>
</ol>
<p>There is a ton of misc logic all over the place of course but almost all of it has already been written and just needs to be pointed at ty::Closure instead of ty::Generator.</p>



<a name="208376821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208376821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208376821">(Aug 28 2020 at 18:09)</a>:</h4>
<p>As for generator functions, iterators, and streams, crates like propane are already dealing with that. They just need this to be stable.</p>



<a name="208377159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208377159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208377159">(Aug 28 2020 at 18:12)</a>:</h4>
<p>Implementation complexity is a non-issue, the language feature needs to be designed first.</p>



<a name="208377415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208377415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208377415">(Aug 28 2020 at 18:15)</a>:</h4>
<p>Fair enough! That is why this discussion is taking place! I hope me, <span class="user-mention" data-user-id="132829">@Christopher Durham</span> ,  pcpthm, and pitaj have refined this down to the bikesheds. But if we hit any big unresolved questions that would absolutely be a reason to defer this.</p>



<a name="208377597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208377597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208377597">(Aug 28 2020 at 18:17)</a>:</h4>
<p>I'm thoroughly excited about this idea, and I'd love to see it happen. My only concern would be whether it's actually through all the bikeshedding at this point.</p>



<a name="208377712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208377712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208377712">(Aug 28 2020 at 18:18)</a>:</h4>
<p>I wouldn't be opposed to, for instance, having the lang team review it, and if there's consensus that this is the right bikeshed color we could approve it, whereas if there's dissensus and a desire for further design, we'd want to defer it rather than chartering a group for it right now.</p>



<a name="208377788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208377788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208377788">(Aug 28 2020 at 18:19)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Thoughts on that? Effectively, a single "go/postpone" decision, without agreeing to do/charter further iterative design work on this?</p>



<a name="208377795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208377795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208377795">(Aug 28 2020 at 18:19)</a>:</h4>
<p>I remember arg reassignment being very controversial the last time it was discussed.</p>



<a name="208377810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208377810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208377810">(Aug 28 2020 at 18:19)</a>:</h4>
<p>/me wasn't aware it was previously discussed.</p>



<a name="208377860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208377860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208377860">(Aug 28 2020 at 18:20)</a>:</h4>
<p>It's definitely a major part of the design. It seems appealing to me given the examples shown. I'm not sure what the alternatives would be.</p>



<a name="208378009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208378009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208378009">(Aug 28 2020 at 18:21)</a>:</h4>
<p>For <code>yield</code> to return a value with the arguments passed in.</p>



<a name="208378024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208378024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208378024">(Aug 28 2020 at 18:21)</a>:</h4>
<p>It got a ton of discussion in RFC-2781 but it's had a year to stew since then. I think the pros on the side of reassignment are pretty solid at this point and it we just have to convince people of that.</p>



<a name="208378675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208378675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208378675">(Aug 28 2020 at 18:26)</a>:</h4>
<p>I literally just summarized some of them under the issue if anyone is curious: <a href="https://github.com/rust-lang/lang-team/issues/49#issuecomment-682986757">https://github.com/rust-lang/lang-team/issues/49#issuecomment-682986757</a></p>



<a name="208379336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208379336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208379336">(Aug 28 2020 at 18:32)</a>:</h4>
<p>Fair enough, I'm convinced.</p>



<a name="208379471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208379471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208379471">(Aug 28 2020 at 18:33)</a>:</h4>
<p>Just to be clear, are the arguments updated by the yield in-place, or do the names always point to the latest arguments of the closure. The difference is that in the first case their address is guaranteed to be constant across multiple closure invocations.</p>



<a name="208380477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208380477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208380477">(Aug 28 2020 at 18:42)</a>:</h4>
<p>The arguments don't live in the closure state unless the user moves them into a binding. Like all arguments they live on the function call stack and thus don't have a stable address. But  don't know if I'd say the names "point" at them. You'll have to explain more what you mean by that.</p>



<a name="208381057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208381057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208381057">(Aug 28 2020 at 18:47)</a>:</h4>
<p>Going into a <code>yield</code> the unmoved arguments get dropped, just like they would going into a <code>return</code>. Coming out of a <code>yield</code>, the bindings receive new values, just like they would when called again after <code>return</code>. But inside the closure the suspension is transparent, so as far as borrow checking is concerned, <code>yield</code> looks like <code>arg = ...</code>.</p>



<a name="208382725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208382725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208382725">(Aug 28 2020 at 19:02)</a>:</h4>
<p>How do you distinguish movable and immovable generators with this proposal? Not at all?</p>



<a name="208382815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208382815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208382815">(Aug 28 2020 at 19:03)</a>:</h4>
<p>I remain unconvinced that mutating the closure arguments after a <code>yield</code> is the right solution. Perhaps that means that we shouldn't try to reuse closure syntax for this at all.</p>



<a name="208388415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208388415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208388415">(Aug 28 2020 at 19:57)</a>:</h4>
<p>I believe that we should be able to infer movability based on the existence of references across yield points. For example, <code>pin_mut!(thing); yield</code> would kill the FnMut implementation (leaving only FnPin + FnOnce) since it constructs a reference which exists until the end of the block. Alternatively, we could instead consider reference liveness (rather than reference existence) and require <code>pin_mut</code> to put a PhantomPinned onto the coroutine stack. An explicit closure modifier is possible to use instead of this inference but I dislike that solution. Especially because closures already do similar work to decide which of Fn/FnMut/FnOnce to implement.</p>



<a name="208388804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208388804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208388804">(Aug 28 2020 at 20:00)</a>:</h4>
<p>The key observation of this proposal is that we aren't really reusing the closure syntax at all. Closures are already so close to being coroutines (have mutable internal state, gain control of execution with arguments, yield execution with an output) that making them unable to yield is nearly an artificial limitation. We aren't overloading a syntax for a new language feature. We are just extending the capabilities of an already powerful part of Rust.</p>



<a name="208389028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208389028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208389028">(Aug 28 2020 at 20:02)</a>:</h4>
<p>Once you see it that way, I think re-assigning the arguments is simply the obvious thing to do: How should we pass arguments? Why, through the arguments of course.</p>



<a name="208389302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208389302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208389302">(Aug 28 2020 at 20:05)</a>:</h4>
<p>Closure syntax only works because they have a single entry point. Once you have multiple entry points, why should all of them use the set of arguments defined at the very first entry point? This does not make much sense to me.</p>



<a name="208389474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208389474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208389474">(Aug 28 2020 at 20:07)</a>:</h4>
<p>Because every entry point takes the same arguments.</p>



<a name="208389807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208389807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208389807">(Aug 28 2020 at 20:10)</a>:</h4>
<p>I don't expect you to really be convinced just because I say I've done it both ways and "trust me". So play around with it a bit.</p>



<a name="208390414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208390414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208390414">(Aug 28 2020 at 20:16)</a>:</h4>
<p>I have – isn't that why you pinged me?</p>



<a name="208390783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208390783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208390783">(Aug 28 2020 at 20:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/243200-t-lang.2Fmajor-changes/topic/Yield.20closures.20lang-team.2349/near/208352589">said</a>:</p>
<blockquote>
<p>I'm not opposed to the idea, but I think that the timing isn't right. I feel like we should be focused on closing up work, not opening large new avenues.</p>
</blockquote>
<p>given the amount of discussion going on, it seems like maybe Niko's original point that we should avoid major new features for now still applies?</p>



<a name="208390981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208390981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208390981">(Aug 28 2020 at 20:22)</a>:</h4>
<p>Of course. You implemented resume arguments for generators, making you an expert on yield-as-an-expression. I was just hoping we could talk about the trade-offs with some more concrete examples. Some people (i.e.  myself a year ago) have a knee-jerk reaction to "magic mutation" since mutation in rust usually means someone is holding your data ransom with a <code>&amp;mut</code>. I've gotten into the habit of looking instead at specific cases when talking about it.</p>



<a name="208391237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208391237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208391237">(Aug 28 2020 at 20:25)</a>:</h4>
<p>Re the amount of discussion: I still have to defend my choice of bikeshed color. I'm just expecting there aren't any new solutions needed that would eat up lang-team resources to develop.</p>



<a name="208890112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890112">(Sep 02 2020 at 21:27)</a>:</h4>
<p>One thing I think we mentioned in the issue that I want to surface up</p>



<a name="208890138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890138">(Sep 02 2020 at 21:27)</a>:</h4>
<p>I think it'd be great to see a comprehensive summary documenting the various design considerations and how you would resolve them</p>



<a name="208890162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890162">(Sep 02 2020 at 21:27)</a>:</h4>
<p>I'd love to see this as a PR for the <a href="https://lang-team.rust-lang.org/design_notes.html">design notes</a> section</p>



<a name="208890179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890179">(Sep 02 2020 at 21:27)</a>:</h4>
<p>I would say that I would be willing to hold off on deciding one way or the other on how much this is in scope until I've had a chance to review that...</p>



<a name="208890235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890235">(Sep 02 2020 at 21:28)</a>:</h4>
<p><span class="user-mention" data-user-id="222520">@Sam Sartor</span> I skimmed the thread above but I confess I skipped past links, does such a summary exist?</p>



<a name="208890251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890251">(Sep 02 2020 at 21:28)</a>:</h4>
<p>I think that'd be an amazing contribution</p>



<a name="208890286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890286">(Sep 02 2020 at 21:28)</a>:</h4>
<p>I've been thinking one through although I don't have time today to write it.</p>



<a name="208890326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890326">(Sep 02 2020 at 21:29)</a>:</h4>
<p>I didnt necessarily mean <em>today</em> :)</p>



<a name="208890367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890367">(Sep 02 2020 at 21:29)</a>:</h4>
<p>and it doesn't have to be "essay quality"</p>



<a name="208890408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890408">(Sep 02 2020 at 21:30)</a>:</h4>
<p>i.e., I think of it more like bullet points and/or links, something to help people get up to speed, not like an RFC</p>



<a name="208890453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890453">(Sep 02 2020 at 21:30)</a>:</h4>
<p>I wrote <a href="http://samsartor.com/coroutines-1">a blog post a while back</a> that did a little bit of summarization, but that was pre-yield-closures. It is actually a bit funny now looking at in in retrospect, when the solution seems so obvious.</p>
<p>Edit: note that blog post does have some factual errors that only got caught in later discussion</p>



<a name="208890852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/208890852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#208890852">(Sep 02 2020 at 21:34)</a>:</h4>
<p>It wouldn't take long at all to bullet-point the remaining bikesheds for yield closures (poison states, enum wrapping). What would take longer is summarizing all the competing proposals which have surfaced over the last couple of years. As many people have observed, generalized coroutines are a huge design space if you don't constrain them somehow (e.g. by extending an existing language  feature instead).</p>



<a name="209166857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/209166857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Sartor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#209166857">(Sep 05 2020 at 07:54)</a>:</h4>
<p>I took a crack at that summary! <a href="https://github.com/samsartor/lang-team/blob/master/src/design_notes/general_coroutines.md">https://github.com/samsartor/lang-team/blob/master/src/design_notes/general_coroutines.md</a></p>
<p>Let me know if there is anything I can add or answer better. I tried to strike a balance between exhaustively detailing our MCP vs trying to put it in the context of prior proposals but I don't know if I found it.</p>



<a name="210048516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Yield%20closures%20lang-team%2349/near/210048516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Yield.20closures.20lang-team.2349.html#210048516">(Sep 14 2020 at 19:01)</a>:</h4>
<p><span class="user-mention" data-user-id="222520">@Sam Sartor</span> awesome!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>